﻿/// <reference name="MicrosoftAjax.js"/>
/// <reference name="Telerik.Web.UI.Common.Core-vsdoc.js" assembly="Telerik.Web.UI" />
/// <reference path="~/Clients/Scripts/jQuery/jquery-1.6.1-vsdoc.js"/>
/// <reference path="~/Clients/Scripts/jQuery/jquery-ui-1.8.13.custom.min.js"/>
/// <reference path="~/Clients/Scripts/jQuery/jquery.ajaxmanager-3.12.debug.js"/>
/// <reference path="~/Clients/Scripts/jQuery/jquery.json.debug.js"/>
/// <reference path="~/Clients/Scripts/jQuery/jquery.component.debug.js"/>
/// <reference path="~/Clients/Scripts/globals.debug.js"/>
/// <reference path="~/Clients/Scripts/utils.debug.js"/>
/// <reference path="~/Clients/Scripts/errorHandling.debug.js"/>
/// <reference path="~/Clients/Scripts/loadingPanels.debug.js"/>
/// <reference path="~/Clients/Scripts/common.debug.js"/>
/// <reference path="~/Clients/Scripts/jqueryLookup.debug.js"/>
/// <reference path="~/Clients/Scripts/url.debug.js"/>
/// <reference path="~/Clients/Scripts/queryObject.debug.js"/>

Type.registerNamespace("IRepairClouds.Controls.Common");

IRepairClouds.Controls.Common.LoginStatus = function(element) {
    IRepairClouds.Controls.Common.LoginStatus.initializeBase(this, [element]);

    this._controlsHolder;
    this._onInitDelegate;
}

IRepairClouds.Controls.Common.LoginStatus.prototype = {
    _controls: function() {
        if (!this._controlsHolder) {
            this._controlsHolder = new (function(element) {
                this.HyperLinkStatus = new GreeNova.JqueryLookup(element, "[id$='HyperLinkStatus']");
            })(this.get_element());
        }
        return this._controlsHolder;
    },

    initialize: function() {
        Sys.Application.add_init(this._onInitDelegate = this._onInit.setCtx(this));
        IRepairClouds.Controls.Common.LoginStatus.callBaseMethod(this, 'initialize');
    },
    dispose: function() {
        if (this._controlsHolder) {
            this._controlsHolder.HyperLinkStatus.jq().unbind();
        }
        Sys.Application.remove_init(this._onInitDelegate);
        IRepairClouds.Controls.Common.LoginStatus.callBaseMethod(this, 'dispose');
    },
    _onInit: function() {
        var controls = this._controls();
        controls.HyperLinkStatus.jq().click(this._onLogout.setCtx(this, { epd: true }));
    },
    _onLogout: function() {
        Sys.Services.AuthenticationService.logout(null, null, null, null);
    }
}
IRepairClouds.Controls.Common.LoginStatus.registerClass('IRepairClouds.Controls.Common.LoginStatus', Sys.UI.Control);
